﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Utility.Persistence_Service;

namespace Utility.Persistence_Service.Implementations
{
    public abstract class RepositoryImpl<T> : Repository<T> where T : class
    {
        protected readonly UnitOfWork unitOfWork;

        public RepositoryImpl(UnitOfWork unitOfWork)
        {
            this.unitOfWork = unitOfWork;
        }

        public T FindById(object id)
        {
            return this.unitOfWork.FindById<T, object>(id);
        }

        public T Create(T value)
        {
            return this.unitOfWork.Create<T>(value);
        }

        public T CreateOrUpdate(T value)
        {
            return this.unitOfWork.CreateOrUpdate<T>(value);
        }

        public T Update(T value)
        {
            return this.unitOfWork.Update<T>(value);
        }

        public void Delete(T value)
        {
            this.unitOfWork.Delete<T>(value);
        }

        public IList<T> FindAll()
        {
            return this.unitOfWork.FindAll<T>();
        }
    }
}
